package com.hddf.project.auth.actions;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

public class BaseAction extends ActionSupport{
	
	public HttpServletResponse getResponse() {
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setContentType("text/html;charset=utf-8");
		response.setHeader("Pragma", "No-Cache");
		response.setHeader("Cache-Control", "No-Cache");
		response.setDateHeader("Expires", 0);
		return response;
	}
	
	public HttpServletRequest getRequest() {
		HttpServletRequest request = ServletActionContext.getRequest();
		
		return request;
	}
	
	public HttpSession getSession() {
		HttpSession session = ServletActionContext.getRequest().getSession();
		return session;
		
	}

	public PrintWriter getOutStream() {
		PrintWriter out = null;
		try {
			out = getResponse().getWriter();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return out;
	}

}
